from model.decision_tree import decision_tree
from model.random_froest import random_forest
from model.svm import svm
from model.knn import knn
from model.stacking import stacking
from model.dnn.dnn import nural_networks
from model.naive_bayes import native_bayes
import functools

from tools.plot_model import plot_multiModel


def compare_models(checkedModel, filePath):
    models_name = ["Decision_Tree", "Stacking", "SVM", "KNN", "Random_Forest", "Deep_Nural_Networks", "Native_Bays"]
    color_list = ['r', 'b', 'y', 'g', 'c', 'm', 'k']
    # 存放选中来比较的模型序号
    models = []
    # 创建函数列表，其中包含了带有参数的函数
    function_list = [decision_tree, random_forest, svm, knn, stacking, nural_networks, native_bayes]
    accuracy_data = []
    precision_data = []
    recall_data = []
    f1_data = []

    # # 使用 functools.partial 创建包装器函数并添加到列表中
    # function_list.append(functools.partial(decision_tree, filePath))
    # function_list.append(functools.partial(random_forest, filePath))
    # function_list.append(functools.partial(svm, filePath))
    # function_list.append(functools.partial(knn, filePath))
    # function_list.append(functools.partial(stacking, filePath))
    # function_list.append(functools.partial(nural_networks, filePath))
    # function_list.append(functools.partial(native_bayes, filePath))

    for i in range(0, 7):
        if checkedModel[i] == 1:
            models.append(i)
        # 依次调用选中的模型算法，得到值
    for mode in models:
        print(models_name[mode], ":")
        fun = function_list[mode]
        accuracy_list, precision_list, recall_list, f1_list = fun(filePath)
        accuracy_data.append(accuracy_list)
        precision_data.append(precision_list)
        recall_data.append(recall_list)
        f1_data.append(f1_list)
    # 绘图
    plot_multiModel(models, models_name, color_list, accuracy_data, precision_data, recall_data, f1_data)